package com.example.design.builder;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;

/**
 * 建造者模式
 */

@Data
@ToString
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public class User {
    private String firstName;
    private String lastName;
    private String county;
    private String city;
    private String town;
    private String detailAddress;
    private String[] languages;
    private String[] project;

    public static class UserBuilder {
        private String firstName;
        private String lastName;
        private String county;
        private String city;
        private String town;
        private String detailAddress;
        private String[] languages;
        private String[] project;


        public UserBuilder setFirstName(String firstName) {
            this.firstName = firstName;
            return this;
        }

        public UserBuilder setLastName(String lastName) {
            this.lastName = lastName;
            return this;
        }

        public UserBuilder setCounty(String county) {
            this.county = county;
            return this;
        }

        public UserBuilder setCity(String city) {
            this.city = city;
            return this;
        }

        public UserBuilder setTown(String town) {
            this.town = town;
            return this;
        }

        public UserBuilder setDetailAddress(String detailAddress) {
            this.detailAddress = detailAddress;
            return this;
        }

        public UserBuilder setLanguages(String[] languages) {
            this.languages = languages;
            return this;
        }

        public UserBuilder setProject(String[] project) {
            this.project = project;
            return this;
        }

        public User build() {
            return new User(firstName, lastName, county, city, town, detailAddress, languages, project);
        }
    }
}
